package com.open.exam.mapper;

import com.open.exam.databasemodel.FreeExamReport;
import org.apache.ibatis.annotations.*;

/**
 * @author 奶茶
 * Created by on 2017/12/12.
 */
@Mapper
public interface FreeExamReportMapper {

    @Select("SELECT * FROM FreeExamReport WHERE AppID = #{appId} AND ExamPlanInfoID = #{planId} AND ExamSubjectID = #{subjectId} AND ExamReport = #{roomId}")
    FreeExamReport getFreeExamReportByWhere(@Param(value = "appId") String appId, @Param(value = "planId") String planId, @Param(value = "subjectId") String subjectId, @Param(value = "roomId") String roomId);

    @Insert("INSERT INTO FreeExamReport (AppID,ExamPlanInfoID,ExamSubjectID,ExamReport,ExamResult,IfUpload,CreateTime) VALUES(#{appID},#{examPlanInfoID},#{examSubjectID},#{examReport},#{examResult},#{ifUpload},NOW())")
    Integer insertFreeExamReport(FreeExamReport freeExamReport);

    @Update("UPDATE FreeExamReport SET IncludeInfo = #{includeInfo},ExamResult = #{examResult},IfUpload = #{ifUpload} WHERE ExamReportID = #{examReportID}")
    Integer updateIncludeInfo(FreeExamReport freeExamReport);

    @Select("SELECT * FROM `FreeExamReport` WHERE ExamReportID = #{examReportID}")
    FreeExamReport getFreeExamReportByID(@Param(value = "examReportID") Integer examReportID);

    @Select("SELECT COUNT(1) FROM freeexamreport WHERE ExamPlanInfoID = #{examPlanID} AND ExamSubjectID = #{examSubjectID}")
    Integer getExamReportCountBYExamPlanIDANDExamSubjectID(@Param(value = "examPlanID") String examPlanID, @Param(value = "examSubjectID") String examSubjectID);
}
